package com.py.credit.clean.code;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

public class SgsDateCheck {
	 public static boolean run(String data, String extend)
	  {	 
	    Calendar cal = Calendar.getInstance();	 
	    Date maxdate = dateChange("2099/12/31");
	    if ((StringUtils.isNotBlank(data)) ) {
	      if ((dateChange(data).compareTo(maxdate) != 1)) {	    	
	        return true;	 
	      }
	    }
	    return false;
	  }

	  public static Date dateChange(String str) {
	    try {
	      if (str.contains("/")) {
	        SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
	        return sf.parse(str);
	      }
	      if (str.contains("-")) {
	        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");

	        return sf.parse(str);
	      }
	    }
	    catch (Exception e)
	    {
	      e.printStackTrace();
	    }

	    return null;
	  }

	  public static void main(String[] args)
	  {
	   String s = "2099/12/31";
	   String s1 = "2100-01-01";
	   String s2 = "2099-12-30";
	
	   
	      System.out.println(run(s, ""));
	      System.out.println(run(s1, ""));
	      System.out.println(run(s2, ""));
	   
	  }
}
